package org.bot.api.flow;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.bot.api.event.Events;

import java.util.HashMap;
import java.util.Map;

@NoArgsConstructor
@Getter
@Setter
public class FlowNode {

    private String flowId; //流程ID

    private boolean isRoot; //是否根节点

    private String nodeId; //节点唯一标识

    private Object driveWeb; //浏览器驱动程序

    private String webWindowName; //指定对应的窗口Web对象，不指定则取默认值

    private String name; //流程名称

    private String arg; //执行命令参数

    private Events event; //业务执行器

    private String selectorType; // 选择器类型

    private String dataIndex; //需要获取的静态索引

    private String staticValue; //需要设置的静态值

    private NodeServiceType flowType; //流程节点所属类型

    private Object extendAttr;

    private boolean debug = false;

    private Map<String, FlowNode> nextNote = new HashMap<>();

    public void setNode(FlowJudgeType flowType, FlowNode node) {
        this.nextNote.put(flowType.name(), node);
    }


    public void setFlowType(String flowType) {
        if (flowType == null) {
            this.flowType = NodeServiceType.SERVICE;
            return;
        }
        switch (flowType) {
            case "judge":
                this.flowType = NodeServiceType.JUDGE;
                break;
            case "service":
            default:
                this.flowType = NodeServiceType.SERVICE;
        }
    }
}
